package com.lpf.www.usercontroller;

import com.lpf.www.common.dto.ResponseMsg;
import com.lpf.www.common.utils.DataHandler;
import com.lpf.www.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author lpf
 * @Date 2022/1/2 下午3:24
 * @ProjectName live-streaming-os
 * @Version 1.0
 * @Description: 用来实现页面跳转的
 */
@Controller
@RequestMapping("user")
public class UserPageController {

    private UserService userService;

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @RequestMapping(value = {"login"})
    public String login(Model model) {
        ResponseMsg responseMsg = userService.getUserInfo();
        model.addAttribute("resData", DataHandler.getJsonString(responseMsg));
        return "userLogin";
    }

    @RequestMapping(value = "register")
    public String register() {
        return "userRegister";
    }

    @RequestMapping("index")
    public String index(){
        return "userIndex";
    }

    @RequestMapping("loginCode")
    public String loginCode(Model model){
        ResponseMsg responseMsg = userService.getUserInfo();
        model.addAttribute("resData", DataHandler.getJsonString(responseMsg));
        return "loginByCode";
    }

    @RequestMapping("head")
    public String head(Model model){
        ResponseMsg responseMsg = userService.getUserInfo();
        model.addAttribute("resData", DataHandler.getJsonString(responseMsg));
        return "head";
    }
    @RequestMapping("userInfo")
    public String userInfo(Model model){
        ResponseMsg responseMsg = userService.getUserInfo();
        model.addAttribute("resData", DataHandler.getJsonString(responseMsg));
        return "userInfo";
    }


    @RequestMapping("userInfoUpdate")
    public String userInfoUpdate(Model model){
        ResponseMsg responseMsg = userService.getUserInfo();
        model.addAttribute("resData", DataHandler.getJsonString(responseMsg));
        return "userInfoUpdate";
    }
}
